<#include "/ftl/lib/operations.ftl"/>
<div class="easyui-layout" fit="true">  
	<div region="north" style="padding:5px;border:1px solid #ddd; background-color: #f4f4f4"  id="global_${action_id}" >
	</div>  
	<div region="center" border="false">
		<div class="easyui-panel" data-options="href:'${request.contextPath}${namespace?default('')}/mp/article/article-list.htm?action_id=${action_id}&channel=${channel}',fit:true">
		</div>
	</div>  
</div>
<script type="text/javascript">

	function add_${action_id}(){
		$('<div>').dialog({
			href : '${request.contextPath}${namespace?default('')}/mp/article/article-form.htm?action_id=${action_id}_0&channel=${channel}',
			width:800,   
			height:600,   
			modal : true,
			title : '${action.getProperty('net.esj.background.message','bg.datagrid.add')}',
			buttons : [ {
				text : '${action.getProperty('net.esj.background.message','bg.datagrid.add')}',
				iconCls : 'icon-edit',
				handler : function() {
					var d = $(this).closest('.window-body');
					$('#form_${action_id}_0').form('submit', {
						url : '${request.contextPath}${namespace?default('')}/mp/article/article-add.json',
						onSubmit: function(){
							return $(this).form('validate');
	    				},
						success : function(json) {
							eval("json="+json);
							$.messager.alert(json.title,json.msg,json.level);
							d.dialog('destroy');
							$("#datagrid_${action_id}").datagrid('reload');
						}
					});
				}
			} ],
			onClose : function() {
				$(this).dialog('destroy');
			}
		});
	}
	
	function edit_${action_id}(data){
		$('<div>').dialog({
			href : '${request.contextPath}${namespace?default('')}/mp/article/article-edit.htm?action_id=${action_id}_2&ajax=false&id='+data.id,
			width:800,   
			height:600,   
			modal : true,
			title : '${action.getProperty('net.esj.background.message','bg.datagrid.edit')}',
			buttons : [ {
				text : '${action.getProperty('net.esj.background.message','bg.datagrid.edit')}',
				iconCls : 'icon-edit',
				handler : function() {
					var d = $(this).closest('.window-body');
					$('#form_${action_id}_2').form('submit', {
						url : '${request.contextPath}${namespace?default('')}/mp/article/article-update.json',
						onSubmit: function(){
							return $(this).form('validate');
	    				},
						success : function(json) {
							eval("json="+json);
							$.messager.alert(json.title,json.msg,json.level);
							d.dialog('destroy');
							$("#datagrid_${action_id}").datagrid('reload');
						}
					});
				}
			} ],
			onClose : function() {
				$(this).dialog('destroy');
			}
		});
	}
	
	function delete_${action_id}(data){
		$.messager.confirm('${action.getText('bg.message.warn')}', '${action.getText('bg.datagrid.delete.ask')}', function(b) {
			if (b) {
				$.ajax({
					url : '${request.contextPath}${namespace?default('')}/mp/article/article-delete.json',
					data:{deletes : data.id},
					dataType : 'JSON',
					success : function(json) {
						$.messager.alert(json.title,json.msg,json.level);
						$("#datagrid_${action_id}").datagrid('reload');
					}
				});
			}
		});
	}
</script>
<@operations contextUri='mp/article/article' />